<?php
namespace Admin\Controller;
use Think\Controller;
class AuntieController extends BaseController {
    	//阿姨管理
	protected function _initialize(){
		parent::_initialize();
	}
	
	
	public function index(){
		//
	}
	//阿姨列表
	public function auntielist(){
		
		$m=M('bb_auntie');
		$p=$_GET['p']?$_GET['p']:1;
		$psize=C('BB_PSIZE')?C('BB_PSIZE'):20;
		if(I('name')){
			$search=I('name');
			$map['name']=array('like',"%$search%");
		}
		$data=$m->where($map)->page($p,$psize)->order('addtime desc')->select();
		$count=$m->where($map)->count();
		$this->getPage($count, $psize, 'bb-loader', '阿姨管理','bb-search');
		foreach ($data as $k => $v){
			$shop=M('bb_shop')->field('name')->where(array('shopid'=>$v['shopid']))->find();
			$data[$k]['shopname']=$shop['name'];
		}
		$this->assign('cache',$data);
		
		$this->display();
	}
	
	
	public function auntieset(){
		$id=I('id');
		$m=M('bb_auntie');
		if(IS_POST){
			$p=I('post.');
			$re=$m->save($p);
			if($re){
				$info['status']=1;
				$info['msg']='修改成功!';
			}else{
				$info['status']=0;
				$info['msg']='修改失败!';
			}
			$this->ajaxreturn($info);
		}
		if($id){
			$cache=$m->where('id='.$id)->find();
			$this->assign('cache',$cache);
		}
		$this->display();
	}
	
}